package face.pay.web.agency.controller;

import face.pay.entity.AgencyLevel;
import face.pay.entity.OemProfitConfigInfo;
import face.pay.entity.UserInfo;
import face.pay.security.annotation.CurrentUser;
import face.pay.security.exception.BaseException;
import face.pay.util.ResultMessage;
import face.pay.util.page.PageData;
import face.pay.util.page.PageParam;
import face.pay.vo.OemUserInfo;
import face.pay.web.agency.service.IAgencyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @Auther: zkj
 * @Date: 2019/7/8 16:00
 * @Description:代理等级设置
 */
@Controller
@RequestMapping(value = "/agency_level")
public class LevelController {

    @Autowired
    private IAgencyService iAgencyService;

    @RequestMapping("/list")
    public String manager(@CurrentUser UserInfo loginUser, Model model){

        OemProfitConfigInfo oemProfitConfigInfo = this.iAgencyService.getProfitConfig(loginUser);

        model.addAttribute("profitConfigInfo",oemProfitConfigInfo);

        return  "agency/levelList";
    }


    @RequestMapping("/edit")
    @ResponseBody
    public ResultMessage editLevel(AgencyLevel agencyLevel) throws BaseException {

        return  this.iAgencyService.editLevel(agencyLevel);

    }


    /**
     * 查询当先登录用户 oem商户 等级设列表
     * @param pageParam
     * @return
     * @throws BaseException
     */
    @RequestMapping("/queryData")
    @ResponseBody
    public PageData data(PageParam pageParam) throws BaseException {

        return  this.iAgencyService.queryPage(pageParam);

    }
}
